#pragma once
#include <map>
class Shader;
class ShaderType;
class VertexFactoryType;
class Material;

//
// ShaderMap
//
class ShaderMap
{
	typedef std::map<const ShaderType*, Shader*> ShaderList;
public:
	ShaderMap();
	~ShaderMap();

	Shader* getShader(const ShaderType* shaderType);

	void Clear();
	void Compile(Material* parent, const VertexFactoryType* vertexFactoryType);

private:
	ShaderList mShaders;
};

//
// MaterialShaderMap
//
class MaterialShaderMap
{
	typedef std::map<const VertexFactoryType*, ShaderMap*> VertexFactoryMap;
public:
	MaterialShaderMap();
	~MaterialShaderMap();
	
	template<class VertexFactory>
	Shader* getShader(const ShaderType* shaderType) const
	{
		return getShader(shaderType, VertexFactory::Type());
	}

	Shader* getShader(const ShaderType* shaderType, const VertexFactoryType* vertexFactoryType) const;

	void Clear();
	void Compile(Material* parent);

private:
	VertexFactoryMap mVertexFactoryMap;
	
	void Compile(Material* parent, const VertexFactoryType* vertexFactoryType);
};

